// pages/scenery/detail/detail.js
var WxParse = require('../../../wxParse/wxParse.js');
var api = require('../../../common/api')
var http = require('../../../utils/http')
Page({
  /**
   * 页面的初始数据
   */
  data: {
    isLike: false,
    isCollect: false,
    sceDetail: {}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let sce = JSON.parse(options.sce)
    this.setData({
      sce: sce
    })
    var self = this;
    http.get(api.SCENERY_DETAIL + '/' + sce.id, null, (res) => {
      console.log(res)
      let content = res.result.brief
      WxParse.wxParse('content', 'html', content, self, 6);
      self.setData({
        sceDetail: res.result
      })
    }, (res) => {
      console.log(res)
    })
  },

  bindLikeTap() {
    this.setData({
      isLike: true
    })
  },
  bindCollectTap() {
    this.setData({
      isCollect: true
    })
  },
  bindShareTap() {
    console.log(1111111111)
    wx.showShareMenu({
      withShareTicket: true,
      menus: ['shareAppMessage', 'shareTimeline']
    })
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    const promise = new Promise(resolve => {
      setTimeout(() => {
        resolve({
          title: '自定义转发标题'
        })
      }, 2000)
    })
    return {
      title: '自定义转发标题',
      path: '/page/user?id=123',
      promise
    }
  },
  onShareTimeline: function () {
    return {
      title: '自定义转发标题',
      query: '/page/user?id=123',
      imageUrl: ''
    }
  }

})